<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box{
      width: 100px;
      height: 100px;
      background-color: hotpink;
      margin-top: 50px;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="changeClass">变化box的类名</button>
    <div :class="{box: flag}"></div>
  </div>
  <script src="../vue.js"></script>
  <script>
    const app =new Vue({
      el: '#app',
      data: {
        flag: true
      },
      methods: {
        changeClass(){
          this.flag = !this.flag
        }
      }
    })
  </script>
</body>
</html>